<div component="composer" class="composer resizable reply" cid="{$cid}" style="visibility: visible;">
	<div class="composer-container">
		<nav class="navbar navbar-fixed-top mobile-navbar visible-xs visible-sm">
			<div class="pull-left">
				<button class="btn btn-default composer-submit" style="font-size:revert;" onclick="window.location.href='{$WEBPATH}/cate/{$cid}'"><i class="fa fa-times"></i> 撤销</button>
			</div>
			<div class="pull-right">
				<button class="btn btn-default composer-submit" style="font-size:revert;" id="submit"><i class="fa fa-check"></i> 提交</button>
			</div>
			<h4 class="title">{$catename}</h4>
		</nav>
		<div class="row title-container">
			<div class="col-lg-12 col-md-12">
				<span class="title form-control">发布帖子到 "{$catename}"</span>
			</div>
		</div>
		<div class="col-lg" style="height:1em;"></div>
        <div class="col-lg">
            <div class="input-group">
                <span class="input-group-addon" style="text-align:center;padding: revert;vertical-align: middle;">标题 <i class="fa fa-fw fa fa-pencil"></i></span>
                <input type="text" class="form-control" id="title" placeholder="输入标题...">
        	<span class="input-group-btn hidden-sm hidden-xs">
        		<button class="btn btn-default composer-discard" onclick="window.location.href='{$WEBPATH}/cate/{$cid}'"><i class="fa fa-times"></i> 撤销</button>
        		<button class="btn btn-primary composer-submit" id="submit"><i class="fa fa-check"></i> 提交</button>
        	</span>                
            </div><!-- /input-group -->
        </div><!-- /.col-lg-6 -->
        <div class="col-lg" style="height:1em;"></div>
        <div class="col-lg">
                <div id="test-editor"></div>
        </div><!-- /.col-lg-6 -->
	</div>
</div>

<script type="text/javascript">
    var editor=loadEditor("test-editor");
</script>
<script>
$('[id="submit"]').click(function(){//发布帖子
    var cid=$('[class="composer resizable reply"]')[0].getAttribute("cid");
    var title=$('#title').val();
    var data={cid:cid,content:editor.getContent(),title:title,token:"{$token}"};
    var pushed=false;
    if(layer!=null){
        pushed=true;
        $.ajax({
            url:"{$WEBPATH}/api/bbs/publish",
            method:"POST",
            dataType:"json",
            data:data,
            success:function(res){
                layer.msg(res.msg);
                if(res.code==200){
                    $('[component="composer"]').css("visibility","hidden");
                    window.location.href="/com/cate/{$cid}";
                }
            }
     });
    }else if(pushed){
        alert("你已提交成功，请勿重复提交");
    }else{
        alert("组件未加载成功,请刷新页面重试");
    }
});
$('[class="btn btn-primary waves-effect waves-button"]').click(function(obj){//发布帖子
    $('[component="composer"]').css("visibility","visible");
});
</script>